package com.lzh.seatrend.config;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

/**
 * @Classname MessageSourceConfig
 * @Description Springboot使用MessageSource读取资源文件
 * @Date 2021/9/24 14:34
 * @Created by liuzihao
 */
@Configuration
public class MessageSourceConfig {

   @Bean
   public MessageSource messageSource(){
       ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
       messageSource.setBasenames("message","code");
       messageSource.setAlwaysUseMessageFormat(true);
       return messageSource;
   }

}
